/*!
 * CodeGenerator(https://git.oschina.net/ptma/CodeGenerator)
 *
 * Date: 2017-11-02 11:30:44
 */
package com.azier.mysql.service;

import com.azier.exception.ServiceException;
import com.azier.mysql.mapper.MonitoringStatsDataDayMapper;
import com.azier.mysql.model.MonitoringStatsDataDay;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.List;

/**
 * 业务层 <br/>
 * Table: monitoring_stats_data_day - 测点日统计数据 <br/>
 *
 * @author 金建强(ptma@163.com)
 * @version 2017-11-02 11:30:44
 */

@Service
@Transactional(rollbackFor = Exception.class)
public class MonitoringStatsDataDayService extends BaseService<MonitoringStatsDataDay>{

    @Autowired
    private MonitoringStatsDataDayMapper monitoringStatsDataDayMapper;

    public void deleteByPrimaryKey(Long statsId) throws ServiceException {
        try {
            monitoringStatsDataDayMapper.deleteByPrimaryKey(statsId);
        } catch (Exception e) {
            throw new ServiceException(e.getMessage(), e);
        }
    }

    public int selectCount() throws ServiceException {
        try {
            return monitoringStatsDataDayMapper.countAllData();
        } catch (Exception e) {
            throw new ServiceException(e.getMessage(), e);
        }
    }

    public List<MonitoringStatsDataDay> selectStatData() throws ServiceException{
        try {
            return monitoringStatsDataDayMapper.selectStatData();
        }catch (Exception e) {
            throw new ServiceException(e.getMessage(), e);
        }
    }

    public List<MonitoringStatsDataDay> selectBySmIdAndTime(HashMap<String,Object> map) throws ServiceException{
        try {
            return monitoringStatsDataDayMapper.selectBySmIdAndTime(map);
        }catch (Exception e) {
            throw new ServiceException(e.getMessage(), e);
        }
    }

    public List<MonitoringStatsDataDay> selectStatDataPage(int pageNum,int pageSize) throws ServiceException {
        try {
            int start = (pageNum-1)*pageSize;
            return monitoringStatsDataDayMapper.selectStatDataPage(start,pageSize);
        }catch (Exception e){
            throw new ServiceException(e.getMessage(), e);
        }

    }
}
